const KoaRouter = require('@koa/router')
const { verifyAuthorization } = require('../middleware/login.middleware')
const { verifyPermission } = require('../middleware/permission.middleware')
const { verifyLabelExist } = require('../middleware/label.middleware')

const momentRouter = new KoaRouter({ prefix: '/moment' })
const monmentController = require('../controller/moment.controller')
const momentController = require('../controller/moment.controller')
// 发送动态 增
momentRouter.post('/', verifyAuthorization, monmentController.create)
// 获取动态列表 查询
momentRouter.get('/', monmentController.list)
// 获取动态详情 查询
momentRouter.get('/:momentId', monmentController.detail)
// 删除动态 删
momentRouter.delete('/:momentId', verifyAuthorization, verifyPermission, momentController.delete)
// 修改动态 改
// 验证：只有登陆的用户才能修改动态
momentRouter.patch('/:momentId',verifyAuthorization, verifyPermission, momentController.update)

// 添加标签 增
momentRouter.post('/:momentId/labels', verifyAuthorization, verifyPermission, verifyLabelExist, momentController.addLabels)

module.exports = momentRouter